import 'package:flutter/material.dart';
import '../model/pdt_detail.dart';
import '../model/recommend_products.dart';

import '../service/service_method.dart';
// import 'dart:convert';

class PdtDetailProvide with ChangeNotifier {
  DdtDetailModel pdtDetail;
  RecommendProductsModel recommendProducts;
  //从后台获取商品信息
  getProductDetail(String code) async {
    final formData = {
      'code': code,
    };
    await request('productDetail', formData: formData).then((val) {
      // var responseData= json.decode(val['productDetail'].toString());
      pdtDetail = DdtDetailModel.fromJson(val);
      notifyListeners();
    });
  }

  getRecommendProducts(String pdpCode) async {
    final formData = {'pdpCode': pdpCode};

    await request('getRecommendProducts', formData: formData).then((val) {
      recommendProducts = RecommendProductsModel.fromJson(val);
      notifyListeners();
    });
  }
}
